using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Collections;

namespace MULENetworking
{
    public delegate void ClientPollCallback(int type, string text);

    interface IChat
    {
        void AddClient(string name);
        void RemoveClient(string name);
        void SendMessage(string newMessage);
        ArrayList Clients { get; }
        String ChatSession { get; }

        event ClientPollCallback MakeClientPoll;
    }

    public class EventShim : MarshalByRefObject
    {
        private ClientPollCallback target;

        private EventShim(ClientPollCallback esTarget)
        {
            target += esTarget;
        }

        public void ClientPollShim(int n, string text)
        {
            target(n, text);
        }

        public static ClientPollCallback Create(ClientPollCallback creTarget)
        {
            EventShim shim = new EventShim(creTarget);
            return new ClientPollCallback(shim.ClientPollShim);
        }
    }
}
